<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // js 继承
    function Person(name, age) {
        console.log(this);
        this.name = name;
        this.age = age;
    }
    // 所有的Person的实例对象（孩子）都可以调用say方法
    Person.prototype.say = function () {
        console.log('hello');
    }



    function Student(name, age, grade) {
        Person.apply(this, [name, age])
        this.grade = grade;
    }

    // 寄生组合式继承
    Student.prototype = Object.create(Person.prototype)

    Student.prototype.study = function () {
        console.log('study');
    }


    const zhangsan = new Student('张三', 18, 1)
    console.log(zhangsan);

    // console.log(zhangsan.name, zhangsan.age);
    zhangsan.say()

</script>

</html>